﻿@using Microsoft.AspNetCore.Http;
@{ 
    Mango.Web.Common.WebSite webSite = new Mango.Web.Common.WebSite();
    Mango.Web.ViewModels.WebSiteViewModel model = webSite.GetWebSiteData();
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"]-@(model.WebSiteConfigData.WebSiteName)[@(model.WebSiteConfigData.WebSiteTitle)]</title>
    <meta name="keywords" content="@(model.WebSiteConfigData.WebSiteKeyWord)" />
    <meta name="description" content="@(model.WebSiteConfigData.WebSiteDescription)" />
    <link href="~/style/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
  
    <link href="~/style/bootstrap/dist/css/offcanvas.css" rel="stylesheet" />
    @RenderSection("Style", required: false)
</head>
<body class="bg-light">
    @{
        string fromUrl = Html.ViewContext.HttpContext.Request.GetAbsoluteUri();
        fromUrl = fromUrl.Contains("register") ? "/home" : fromUrl;
    }
    <nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="/">51Core.Net</a>
            <div class="collapse navbar-collapse" id="navbarCollapse">
                <ul class="navbar-nav mr-auto" id="topNavgationTag">
                    
                    @Html.PartialAsync("~/Views/Template/Navigation.cshtml", model).Result
                </ul>
            </div>
            <div class="navbar-right" id="navbarCollapse" style="float:right;display:block;">

                @if (Html.ViewContext.HttpContext.Session.GetInt32("AccountId") == null)
                {
                    <ul class="navbar-nav mr-auto">
                        @if (model.WebSiteConfigData.IsLogin)
                        {
                            <li class="nav-item  @(Html.ViewContext.RouteData.Values["action"].ToString().ToLower() == "login" ? "active" : "")"><a class="nav-link" href="/account/login?fromurl=@(fromUrl)">登录</a></li>
                        }
                        @if (model.WebSiteConfigData.IsRegister)
                        {
                            <li class="nav-item  @(Html.ViewContext.RouteData.Values["action"].ToString().ToLower() == "register" ? "active" : "")"><a class="nav-link" href="/account/register">注册账号</a></li>
                        }
                    </ul>
                }
                else
                {
                    <div class="navbar-nav mr-auto">
                        <div class="btn-group">
                            <button type="button" class="btn btn-secondary" id="msg_push_showlist">
                                @Html.ViewContext.HttpContext.Session.GetString("NickName")
                                <span class="badge badge-light" id="msg_push_count">0</span>
                            </button>
                            <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <span class="sr-only">Toggle Dropdown</span>
                            </button>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="/cms/release">发布文章</a>
                                <a class="dropdown-item" href="/docs/release/theme">发布文档</a>
                                <a class="dropdown-item" href="/account/my/info">个人中心</a>
                                <a class="dropdown-item" href="/account/login/outlogin">退出登录</a>
                            </div>
                        </div>
                    </div>
                }

            </div>
        </div>

    </nav>
    <main role="main" class="container">
        @RenderBody()
    </main>



    <div class="container">
        <hr />
        <div class="row text text-center">
            <div class="col-lg-12">
                @(model.WebSiteConfigData.CopyrightText)
            </div>
            <div class="col-lg-12">
                <a href="http://www.miitbeian.gov.cn" target="_blank">@(model.WebSiteConfigData.FilingNo)</a>
            </div>
        </div>
    </div>

    <script src="~/js/appconfig.js"></script>
    <script src="~/lib/jquery/jquery-3.3.1.min.js"></script>
    <script src="~/style/bootstrap/dist/js/bootstrap.min.js"></script>

    <script src="~/lib/layer/layer.min.js"></script>
    <script src="~/lib/artdialog/dialog.js"></script>

    <script src="~/js/main.min.js"></script>
    @if (Html.ViewContext.HttpContext.Session.GetString("AccountId") != null)
    {
        <script type="text/javascript">
            var signalrServerUrl = '@(Mango.Core.Configuration.GetItem("ApiServerUrl"))';
            var signalRUserId ='@Html.ViewContext.HttpContext.Session.GetString("UserId")';
        </script>
        <script src="~/lib/signalr/dist/browser/signalr.min.js"></script>
        <script src="~/js/message.js"></script>
        <script type="text/javascript">
            //设置用户登录状态
            isUserLogin = true;
            //
            $("#msg_push_showlist").click(function () {

                //加载数据
                $.ajax({
                    type: 'get',
                    url: '/message/GetMessageList',
                    success: function (res) {
                        var html = '';
                        html += '<table class="table table-sm" style="overflow-y:auto;" id="msg_push_list_data">';
                        html += '<tbody>';

                        $.each(res, function (i, item) {
                            console.log(item);
                            html += '<tr><td>' + item.contents + '</td></tr>';
                        });
                        html += '</tbody>'
                        html += '</table>';
                        var d = dialog({
                            title: '新消息通知',
                            content: html,
                            height: 300,
                            width: 500,
                            id: 'msg_push_list_dialog'
                        });
                        d.show(document.getElementById("msg_push_showlist"));
                        $("#msg_push_list_data").parent().attr("style", $("#msg_push_list_data").parent().attr("style") + "overflow-y:scroll;");
                        $("#msg_push_count").text("0");
                        //更改未读消息状态
                        $.ajax({
                            type: 'post',
                            url: '/message/UpdateReadState',
                            success: function (res) {
                                console.log(res);
                            }
                        });
                    }
                });
            });
        </script>
    }
    <script type="text/javascript">
        var controllerName = "@Html.ViewContext.RouteData.Values["controller"].ToString().ToLower()";
        $("#topNavgationTag").find("li").each(function (i) {
            if ($(this).attr('data-id').indexOf(controllerName) > -1) {
                $(this).addClass("active");
            }
        });
    </script>
    @RenderSection("Scripts", required: false)

</body>
</html>
